package cn.funeralobjects.minecraft.api;

import cn.funeralobjects.minecraft.api.mapper.PlayerMapper;
import cn.funeralobjects.minecraft.api.model.SimplePlayerVo;
import cn.funeralobjects.minecraft.service.MinecraftServerService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import javax.annotation.Resource;

/**
 * @author FuneralObjects
 * Create date: 2021/5/5 10:45 PM
 */
@RestController("/api/player")
public class PlayerApi {

    @Resource
    private MinecraftServerService minecraftServerService;

    @GetMapping("/all")
    public Flux<SimplePlayerVo> getAllPlayers() {
        return minecraftServerService.getPlayers().map(PlayerMapper.INSTANCE::toSimpleVo);
    }


}
